sysroot: Add ostree_sysroot_write_origin_file() API
authorColin Walters <walters@verbum.org>
Fri, 16 Jan 2015 18:04:29 +0000 (13:04 -0500)
committerColin Walters <walters@verbum.org>
Mon, 19 Jan 2015 18:45:11 +0000 (13:45 -0500)
We want to allow admins to change the origin file without doing a new
deployment, so this will be part of a future "admin set-origin"
command.

src/libostree/ostree-sysroot-deploy.c
src/libostree/ostree-sysroot.h

index d5c6811e33807d95088013a7497c5aab7ce0d98c..b3289327cf5d30e887dd78fea26ab114c0c893d5 100644 (file)
@@ -949,14 +949,28 @@ merge_configuration (OstreeSysroot         *sysroot,
   return ret;
 }
 
-static gboolean
-write_origin_file (OstreeSysroot         *sysroot,
-                   OstreeDeployment      *deployment,
-                   GCancellable      *cancellable,
-                   GError           **error)
+/**
+ * ostree_sysroot_write_origin_file:
+ * @sysroot: System root
+ * @deployment: Deployment
+ * @new_origin: (allow-none): Origin content
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Immediately replace the origin file of the referenced @deployment
+ * with the contents of @new_origin.  If @new_origin is %NULL,
+ * this function will write the current origin of @deployment.
+ */
+gboolean
+ostree_sysroot_write_origin_file (OstreeSysroot         *sysroot,
+                                  OstreeDeployment      *deployment,
+                                  GKeyFile              *new_origin,
+                                  GCancellable          *cancellable,
+                                  GError               **error)
 {
   gboolean ret = FALSE;
-  GKeyFile *origin = ostree_deployment_get_origin (deployment);
+  GKeyFile *origin =
+    new_origin ? new_origin : ostree_deployment_get_origin (deployment);
 
   if (origin)
     {
@@ -1879,7 +1893,8 @@ ostree_sysroot_deploy_tree (OstreeSysroot     *self,
       goto out;
     }
 
-  if (!write_origin_file (self, new_deployment, cancellable, error))
+  if (!ostree_sysroot_write_origin_file (self, new_deployment, NULL,
+                                         cancellable, error))
     {
       g_prefix_error (error, "Writing out origin file: ");
       goto out;
index 7bfda2c81e47cb387ba0e4026b7ca45b06bc56fe..2044b923ebf014d21420c2c3f45d51035d91f4bc 100644 (file)
@@ -61,6 +61,12 @@ gboolean ostree_sysroot_cleanup (OstreeSysroot       *self,
                                  GCancellable        *cancellable,
                                  GError             **error);
 
+gboolean ostree_sysroot_write_origin_file (OstreeSysroot         *sysroot,
+                                           OstreeDeployment      *deployment,
+                                           GKeyFile              *new_origin,
+                                           GCancellable          *cancellable,
+                                           GError               **error);
+
 gboolean ostree_sysroot_get_repo (OstreeSysroot         *self,
                                   OstreeRepo           **out_repo,
                                   GCancellable          *cancellable,